#!/usr/bin/env bash
apt-get update | grep "Hit http\|Ign http" -C 10000 && echo "There are possible failures on fetching. Try apt-get update again"

apt-get update
apt-get upgrade -y
apt-get install python3-setuptools -y

apt-get install git -y
git clone https://github.com/gastonfeng/install-odoo.git
cd install-odoo
git checkout 11.0


# run script with parameters you need
# (list of all parameters with default values can be found at install-odoo-saas.sh)
INSTALL_DEPENDENCIES=yes \
INIT_POSTGRESQL=yes \
INIT_BACKUPS=yes \
INIT_NGINX=yes \
INIT_START_SCRIPTS=yes \
INIT_ODOO_CONFIG=yes \
INIT_USER=yes \
INIT_DIRS=yes \
CLONE_ODOO=yes \
CLONE_IT_PROJECTS_LLC=yes \
CLONE_OCA=yes \
UPDATE_ADDONS_PATH=yes \
ADD_AUTOINSTALL_MODULES="['ir_attachment_force_storage']" \
/bin/bash -x install-odoo-saas.sh

# show settings (admin password, addons path)
head /etc/openerp-server.conf
# show odoo version
grep '^version_info ' $ODOO_SOURCE_DIR/openerp/release.py

# PGTune: http://pgtune.leopard.in.ua/"

# log
tail -f -n 100 /var/log/odoo/odoo-server.log

# start from console (for ODOO_USER=odoo):
sudo su - odoo -s /bin/bash -c  "/usr/local/src/odoo-source/odoo-bin -c /etc/openerp-server.conf"

# psql (use name of your database)
sudo -u odoo psql DATABASE

# some common issues:
# https://www.odoo.com/forum/help-1/question/dataerror-new-encoding-utf8-is-incompatible-with-the-encoding-of-the-template-database-sql-ascii-52124

